package com.yu.waterstation.system.modules.app.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.waterstation.common.common.annotation.AdminLog;
import com.yu.waterstation.common.common.annotation.NeedPermission;
import com.yu.waterstation.common.common.enums.OrderStatus;
import com.yu.waterstation.common.common.exception.ServiceException;
import com.yu.waterstation.common.common.util.result.Result;
import com.yu.waterstation.common.entity.app.TicketGoods;
import com.yu.waterstation.common.entity.app.TicketOrder;
import com.yu.waterstation.common.entity.system.Role;
import com.yu.waterstation.common.entity.system.form.UpdateRolePermissionVo;
import com.yu.waterstation.system.modules.app.service.impl.TicketGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "商品管理")
@RestController
@RequestMapping("/system/ticketGoods")
public class TicketGoodsController {

    @Resource
    private TicketGoodsService ticketGoodsService;

    @ApiOperation("所有商品")
    @NeedPermission("system:ticketGoods:list")
    @GetMapping
    public Result<List<TicketGoods>> listGoods() {
        return Result.ok(ticketGoodsService.listGoods());
    }

    @ApiOperation("增")
    @AdminLog
    @NeedPermission("system:ticketGoods:add")
    @PostMapping
    public Result add(@RequestBody TicketGoods goods) {
        return Result.ok(ticketGoodsService.insertGoods(goods));
    }

    @ApiOperation("改")
    @AdminLog
    @NeedPermission("system:ticketGoods:update")
    @PutMapping
    public Result update(@RequestBody TicketGoods goods) {
        return Result.ok(ticketGoodsService.updateGoodsById(goods));
    }

    @ApiOperation("删")
    @AdminLog
    @NeedPermission("system:ticketGoods:delete")
    @DeleteMapping("/{goodsId}")
    public Result delete(@PathVariable Integer goodsId) {
        return Result.ok(ticketGoodsService.deleteGoodsById(goodsId));
    }

}
